﻿using System;
using System.Collections.Generic;
using System.Web;

/// <summary>
///DelayWeiboProxy 的摘要说明
/// </summary>
public class DelayWeiboProxy
{
	public DelayWeiboProxy()
	{
	}

    public object Add(string weiboId, string reply, string replyAccount, DateTime replyTime, string commentId)
    {
        DBDelaySendWeibo db = new DBDelaySendWeibo();
        if (weiboId == "0" || db.Select(weiboId) == null)
        {
           int id=  db.Add(weiboId, reply, replyAccount, replyTime, DateTime.UtcNow, commentId);
            new DealedWeiboProxy().Update(weiboId, (int)DealWeiboStatusEnum.REPLIED);
            return db.Select(id);
        }
        else
            return "此微博已添加定时回复";
    }

    public DelayWeiboData Update(int id, string reply)
    {
          DBDelaySendWeibo db = new DBDelaySendWeibo();
          DelayWeiboData data = db.Select(id);
          if (data == null)
              return null;
          else
          {
              db.Update(id, reply);
              return db.Select(id);
          }
    }

    public DelayWeiboData Delete(int id)
    {
        DBDelaySendWeibo db = new DBDelaySendWeibo();
        DelayWeiboData data = db.Select(id);
        if (data != null)
        {
            db.Delete(id);
            return data;
        }
        return null;
    }

    public List<DelayWeiboData> SelectDelayList()
    {
        return new DBDelaySendWeibo().SelectList();
    }
}